<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>{:COMPANY}</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="description" content="">
        <meta name="keywords" content="coco bootstrap template, coco admin, bootstrap,admin template, bootstrap admin,">
        <meta name="author" content="Huban Creative">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <!-- Base Css Files -->
        <link href="{:__BOOTSTRAP__}css/bootstrap.min.css" rel="stylesheet" />
        <link href="{:__CSS__}font-awesome/css/font-awesome.min.css" rel="stylesheet" />
        <link href="{:__CSS__}fontello/css/fontello.css" rel="stylesheet" />

        <!-- Extra CSS Libraries Start -->
        <link href="{:__CSS__}style.css" rel="stylesheet" type="text/css" />
        <!-- Extra CSS Libraries End -->

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->

        <link rel="shortcut icon" href="{:__IMG__}Besiness/favicon.ico">
    </head>

    <body>
        <!-- Start content-->
        <div class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="widget">
                        <div class="widget-header transparent">
                            <h2><strong>热门搜索列表</strong></h2>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-hover table-striped">
                                <thead>
                                    <tr>
                                        <th>搜索词</th>
                                        <th>搜索次数</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <foreach name="re" item="v">
                                    <tr class="hid_{$v.hid}">
                                    <input type="hidden" name="hid" value="{$v.hid}"/>
                                    <td>{$v.field}</td>
                                    <td class="shu">{$v.count}</td>
                                    <td>
                                        <div class="btn-group btn-group-xs">
                                            <a href="javascript:del_hot({$v.hid})" tit="删除" class="btn btn-default"><i class="fa fa-times"></i></a>  
                                        </div>
                                    </td>
                                    </tr>
                                </foreach>                                
                                </tbody>
                            </table>
                        </div>
                        <div class="my_page">{$page}</div>
                    </div>
                </div>
            </div
            <!-- Footer Start -->
            <div class="footer">Copyright &copy; {:COMPANY}</div>
            <!-- Footer End -->
        </div>

        <script type="text/javascript" src="{:__LIBS__}jquery/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="{:__LIBS__}layer/layer.js"></script>
        <script type="text/javascript" src="{:__JS__}common.js"></script>
        <script>
            function del_hot(hid) {
                if (confirm("你确定要删除吗？")) {
                    $.ajax({
                        url: '__APP__/Admin/Hotsearch/del_hot',
                        type: 'post',
                        data: 'hid=' + hid,
                        datatype: 'json',
                        success: function (re) {
                            if (re.val == 1) {
                                $('.hid_' + hid).remove();
                            } else {
                                alert(re.str);
                            }
                        }
                    })
                }
            }
            $(function () {
                $('.shu').bind('mouseover', function () {
                    $('.shu').css('cursor', 'pointer');
                })
                $('.shu').bind('click', function () {
                    var td = $(this);
                    var hid = td.prev().prev().val();
                    var text = $(this).text()
                    var input = $("<input type='text' class='count' value='" + text + "'/>");
                    td.html(input)
                    input.trigger("focus");
                    input.blur(function () {
                        var newtext = $(this).val();
                        if (newtext == '') {
                            newtext = 0;
                        }
                        if(newtext != text){
                            td.html(newtext);
                            $.ajax({
                                url: '__APP__/Admin/Hotsearch/hot_count_up',
                                type: 'post',
                                data: 'count=' + newtext + '&hid=' + hid,
                                datatype: 'json',
                                success: function (re) {
                                    if (re.val == 1) {
                                        window.location.reload();
                                    } else {
                                        alert(re.str);
                                    }
                                }
                            })

                        } else {
                            window.location.reload();
                        }
                    })
                })
            })
        </script>
    </body>

</html>